Add support for a custom arguments list when running main.
authorClark Gaebel <cgaebel@mozilla.com>
Fri, 12 Dec 2014 20:54:14 +0000 (12:54 -0800)
committerClark Gaebel <cgaebel@mozilla.com>
Fri, 12 Dec 2014 21:05:55 +0000 (13:05 -0800)
src/cargo/lib.rs
src/cargo/sources/path.rs

index e2b99336e63dc850cf33ce3e559c632ffc307fcd..2dd20824f90d279485deff16d65ced0953c942a4 100644 (file)
@@ -116,6 +116,20 @@ pub fn execute_main_without_stdin<'a,
                                                        options_first));
 }
 
+pub fn execute_main_with_args_and_without_stdin<'a,
+                                  T: Decodable<docopt::Decoder, docopt::Error>,
+                                  V: Encodable<json::Encoder<'a>, io::IoError>>(
+                                      exec: fn(T, &mut MultiShell) -> CliResult<Option<V>>,
+                                      options_first: bool,
+                                      usage: &str,
+                                      args: &[String]) {
+    let mut shell = shell(true);
+
+    process_executed(
+        call_main_without_stdin(exec, &mut shell, usage, args, options_first),
+        &mut shell)
+}
+
 pub fn call_main_without_stdin<'a,
                                T: Decodable<docopt::Decoder, docopt::Error>,
                                V: Encodable<json::Encoder<'a>, io::IoError>>(
index 731e4835e5811f5921849fb4cb68c500dda85828..d6a012fc571db8b24ee9c19878cdedcd3a72a40e 100644 (file)
@@ -51,7 +51,7 @@ impl PathSource {
         }
     }
 
-    fn read_packages(&self) -> CargoResult<Vec<Package>> {
+    pub fn read_packages(&self) -> CargoResult<Vec<Package>> {
         if self.updated {
             Ok(self.packages.clone())
         } else {